import goodStorage from 'good-storage'

export class ImgUtil {
    static imgList = {}
    static storageImgList(){
        this.imgList = goodStorage.get('imgList') || {}
    }
    static isEmpty(){
        return !Object.getOwnPropertyNames(this.imgList).length
    }
    static loadAllImage(){
        const imgMap = import.meta.globEager('@/assets/**/*')
        let absolutePaht = ""
        for(let relativePath in imgMap){
            absolutePaht = (imgMap[relativePath].default)
            const imageName = absolutePaht.substring(absolutePaht.lastIndexOf("/")+1)
            this.imgList[imageName] = absolutePaht
        }
        goodStorage.set('imgList',this.imgList)
    }
    static getImg(imageName){
        return ImgUtil.imgList[imageName]
    }
}

export default ImgUtil.getImg